# Contributor: David Demelier <markand@malikania.fr>
# Maintainer: David Demelier <markand@malikania.fr>
pkgname=irccd
pkgver=4.0.1
pkgrel=1
pkgdesc="IRC Client Daemon"
url="http://projects.malikania.fr/irccd"
arch="all"
license="ISC"
makedepends="bison cmake curl-dev flex openssl-dev"
subpackages="$pkgname-doc $pkgname-dev $pkgname-openrc"
source="http://releases.malikania.fr/irccd/$pkgver/irccd-$pkgver.tar.xz
	irccd.initd
	irccd.confd"
pkgusers="irccd"
pkggroups="irccd"
options="!check" # Fixed in next version.

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DIRCCD_WITH_TESTS=Off \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -Dm644 -o "$pkgusers" -g "$pkggroups" \
		"$pkgdir"/etc/irccd.conf.sample "$pkgdir"/etc/irccd.conf

	install -Dm755 "$srcdir"/irccd.initd "$pkgdir"/etc/init.d/irccd
	install -Dm644 "$srcdir"/irccd.confd "$pkgdir"/etc/conf.d/irccd
}

sha512sums="
08784d62d5f9b17f5e54d32a6cee7a65dcf82c41ed2563144e408c7575f407d90eb1f76b8136a10ce0255b51d061770c2f16504938cfff90c36d4b504f092f1a  irccd-4.0.1.tar.xz
0ae7907a9724a55e30eac5d19c6b1e5e83ddea6ee90a8a377030f521de9c28c9cec103fbce4fc097ac59f55b7048bc9dee395affd9300de3a79ac2e86d0c75d0  irccd.initd
93ce8795790a21e87cdfb9d31737af73faa200244c448841cd65e52f0523e8f664151e61dbf431df8360473d73c3ca5b3b8b6bcb0ccec52f66e511ae9f2abbdb  irccd.confd
"
